#include "subscriberactivator.h"

#include <QDebug>
#include <service/event/ctkEventConstants.h>

void SubscriberActivator::start(ctkPluginContext *context)
{
    Q_UNUSED(context)
    qDebug() << Q_FUNC_INFO << "插件启动" << "订阅";
    //订阅 "topic/subscriber_publisher_demo"
    ctkDictionary props;
    props.insert(ctkEventConstants::EVENT_TOPIC, "topic/subscriber_publisher_demo");
    context->registerService<ctkEventHandler>(this, props);
}

void SubscriberActivator::stop(ctkPluginContext *context)
{
    Q_UNUSED(context)
}

void SubscriberActivator::handleEvent(const ctkEvent &event)
{
    qDebug() <<  Q_FUNC_INFO << "username:" << event.getProperty("username");
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
Q_EXPORT_PLUGIN2(Subscriber, SubscriberActivator)
#endif
